home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_sequencer_m.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  192 lines

  1. # Jedi Knight MOTHS Cog Script
  2. #
  3. # POW_SEQUENCER.COG
  4. #
  5. # POWERUP Script - Sequencer
  6. #
  7. # [YB, CYW, SRS]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. template    explode=+large_exp               local
  15.  
  16. thing       powerup                          local
  17. thing       player                           local
  18. thing       sender                           local
  19.  
  20. int         bin=8                            local
  21. sound       pickupsnd=thrmlpu2.wav           local
  22. sound       respawnsnd=Activate01.wav        local
  23. flex        amount                           local
  24.  
  25. int         bin_contents=0                   local
  26. int         autopickup=0                     local
  27. int         autosel=-1                       local
  28. int         damage                           local
  29.  
  30. message     created
  31. message     damaged
  32. message     touched
  33. message     taken
  34. message     respawn
  35. message     timer
  36.  
  37. end
  38.  
  39. # ========================================================================================
  40.  
  41. code
  42.  
  43. created:
  44.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  45.    Return;
  46.  
  47. # ........................................................................................
  48.  
  49. touched:
  50.    if (GetWeaponBin(bin) == -1)
  51.       return;
  52.  
  53.    player = GetSourceRef();
  54.  
  55.    if (GetThingType(player) == 10)  // Can only be taken by players.
  56.    {
  57.       amount = GetInv(player, GetWeaponBin(bin));
  58.  
  59.       if (IsMulti() || (amount < GetInvMax(player, GetWeaponBin(bin))))
  60.       {
  61.          TakeItem(GetSenderRef(), -1);
  62.          call taken;
  63.       }
  64.    }
  65.  
  66.    Return;
  67.  
  68. # ........................................................................................
  69.  
  70. damaged:
  71.    sender = GetSenderRef();
  72.  
  73.    // only take damage 33% of the time
  74.    if(rand() < 0.33)
  75.       return;
  76.  
  77.    // If it's already dead, don't allow any more damage.
  78.    if (!GetThingUserData (sender))
  79.       return;
  80.  
  81.    damage = GetParam (0);
  82.  
  83.    // see if this will cause the explosion
  84.    if (GetThingUserData (sender) <= damage)
  85.    {
  86.       SetThingUserData(sender, 0);
  87.  
  88.       // timer for base explosion
  89.       SetTimerEx ((Rand () * 0.5), sender, 1, 0);
  90.    }
  91.    else
  92.    {
  93.       SetThingUserData(sender, GetThingUserData (sender) - damage);
  94.    }
  95.  
  96.    ReturnEx (0);
  97.    return;
  98.  
  99. # ........................................................................................
  100.  
  101. taken:
  102.    if (GetWeaponBin(bin) == -1)
  103.       return;
  104.  
  105.    powerup = GetSenderRef();
  106.  
  107. // // If the object has been destroyed, don't award it to the player.
  108. //   if (!GetThingUserData (powerup))
  109. //    return;
  110.  
  111.    player = GetSourceRef();
  112.  
  113.    // Print("Sequencer Charges");
  114.    jkPrintUNIString(player, GetWeaponBin(bin));
  115.  
  116.    // Do effects.
  117.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  118.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  119.  
  120.    // store the old bin contents
  121.    bin_contents = GetInv(player, GetWeaponBin(bin));
  122.  
  123.    // Increment powerup amount.
  124.    ChangeInv(player, GetWeaponBin(bin), 5.0);
  125.  
  126.    // For both uses.
  127.    if (!GetInv(player, GetWeaponBin(bin+10)))
  128.       SetInv(player, GetWeaponBin(bin+10), 1.0);
  129.  
  130.    // Check for Auto Pickup
  131.    autopickup = GetAutoPickup();
  132.    if((autopickup & 1) && !(autopickup & 2)) // DANGEROUS
  133.    {
  134.       if(!bin_contents)
  135.       {
  136.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player)), 0) >= GetWeaponPriority(player, GetWeaponBin(bin), 0))))
  137.          {
  138.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  139.             {
  140.                   // Don't switch weapons if we are in manual mode already!
  141.                if (GetCurWeapon(player) != (bin + 10))
  142.                   SelectWeapon(player, GetWeaponBin(bin));
  143.                Return;
  144.             }
  145.          }
  146.       }
  147.    }
  148.  
  149.    // Check for Auto Reload
  150.    if(GetAutoReload() & 1)
  151.    {
  152.       if(!bin_contents)
  153.       {
  154.          if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  155.          {
  156.             // Try to autoselect and see if the best weapon is the sequencer
  157.             autosel = AutoSelectWeapon(player, 2);
  158.  
  159.             if((autosel % 10) == 8)
  160.                   // Don't switch weapons if we are in manual mode already!
  161.                if (GetCurWeapon(player) != (bin + 10))
  162.                   SelectWeapon(player, autosel);
  163.          }
  164.       }
  165.    }
  166.  
  167.    return;
  168.  
  169. # ........................................................................................
  170.  
  171. respawn:
  172.    SetThingUserData(GetSenderRef(), 30);     // set the initial user data (i.e. "health")
  173.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  174.  
  175.    return;
  176.  
  177. # ........................................................................................
  178.  
  179. timer:
  180.    sender = GetSenderId ();
  181.  
  182.    powerup = CreateThingNR(explode, sender);
  183.  
  184.    // Since the user data is 0, the player won't actually be awarded this powerup.
  185.    TakeItem (sender, -1);
  186.    return;
  187.  
  188. end
  189.  
  190.  
  191.  
  192.